
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
            <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no minimal-ui"/>
            <meta name="format-detection" content="telephone=no"/>
            <meta name="apple-mobile-web-app-capable" content="yes">
                <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache,no-store, must-revalidate">
                    <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
                        <meta HTTP-EQUIV="expires" CONTENT="0">
                            <!--<script src="jquery.js" type="text/javascript" charset="utf-8"></script>-->
                            <style>
                                .left,.right{ float: left; }
                                .right{width:30%;}
                                .left{border:1px solid #666; padding: 20px 20px;width:90%}
                                button{border:0px solid #fff; background: #f1f1f1; padding: 20px 20px; border-radius: 10px 10px;-moz-border-radius: 10px 10px;-webkit-border-radius: 10px 10px; margin-bottom: 10px; font-size: 1rem;}
                                .left h1{ text-align: center; border-top:1px solid #666; padding-top: 10px; font-size: 1rem; }
                                .right h1{  padding-top: 10px; font-size: 1rem; }
                                input { width: 100%; text-align: center; border-radius: 10px 10px;-moz-border-radius: 10px 10px;-webkit-border-radius: 10px 10px; padding: 20px 0px; border:1px solid #999; background: none; margin-bottom: 10px;}
                                .b1{padding:20px 20px; width: 40%}
                                .b2{padding:20px 20px; width: 40%; float: right;}
                                .h1{border: none;}
                                .b3{padding:20px 20px; width: 100%}
                                .right{margin-left: 60px;}
                                </style>
                            
                            <script type="text/javascript">
                                
                                /**
                                 js调用app接口方法用例
                                 
                                 function demo(param1, param2){
                                 if(isAndroid){
                                 window.wst.demo();
                                 }else{
                                 WebViewJavascriptBridge.callHandler('demo',{param1,param2}, function(response) {})
                                 
                                 }
                                 }
                                 */
                            
                            function connectWebViewJavascriptBridge(callback) {
                                if (window.WebViewJavascriptBridge) {
                                    callback(WebViewJavascriptBridge)
                                } else {
                                    document.addEventListener('WebViewJavascriptBridgeReady', function() {
                                                              callback(WebViewJavascriptBridge)
                                                              }, false)
                                }
                                
                            }
                            
                            function get_location(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                if(isAndroid){
                                    window.wst.get_location();
                                }else{
                                    // WebViewJavascriptBridge.callHandler('get_location','', function(response) {})
                                    window.webkit.messageHandlers.get_location.postMessage();
                                }
                            }
                            
                            /*
                             调用时传name参数和上传文件url的参数，根据需要自行修改
                             */
                            function call_mic(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                var name = "name";
                                var url = 'http://www.mysmartabc.com/abcd/lmsm/recordaudio/eduapp/uploadMP3.aspx';
                                //var url = 'http://www.i-craftsmen.com/production/ebookdemo/upload_mp3.php'
                                var videoName = 'BlueSong';
                                var videoURL = 'http://www.mysmartabc.com/nsb/abcd/video/EBook/BLUE_SONG/video.mp4';
                                if(isAndroid){
                                    window.wst.call_mic(name, url);//传name和上传url参数
                                }else{
                                    //WebViewJavascriptBridge.callHandler('call_mic',{name:name,url:url}, function(response) {})
                                    var message = {
                                        'method' : 'openappurl',
                                        'params' : {
                                            'url' : url,
                                            'name': name
                                        }
                                    };
                                    window.webkit.messageHandlers.call_mic.postMessage(message);
                                }//传name和上传url参数
                            }
                            
                            function call_mic2(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                var name = "name";
                                var url = 'http://www.mysmartabc.com/abcd/lmsm/recordaudio/eduapp/uploadMP3.aspx';
                                //var url = 'http://www.i-craftsmen.com/production/ebookdemo/upload_mp3.php'
                                var videoName = 'video.mp4';
                                var videoURL =  "http://www.mysmartabc.com/nsb/abcd/video/EBook/BLUE_SONG/video.mp4";
                                if(isAndroid){
                                    window.wst.call_mic(name, url,videoName,videoURL);//传name和上传url参数
                                }else{
                                    //WebViewJavascriptBridge.callHandler('call_mic',{name:name,url:url,videoName:videoName,videoURL:videoURL},
                                    //function(response){})
                                    var message = {
                                        'method' : 'openappurl',
                                        'params' : {
                                            'url' : url,
                                            'name': name
                                        }
                                    };
                                    window.webkit.messageHandlers.call_mic2.postMessage(message);
                                }//传name和上传url参数
                            }
                            /*
                             调用app时传name参数和上传文件url的参数，根据需要自行修改
                             */
                            function call_camera(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                var name = "123-456";
                                var url = 'http://aa.mysmartedu.com.cn/aapowerapi/upload_photo.php';
                                if(isAndroid){
                                    window.wst.call_camera(name, url);//传name和上传url参数
                                }else{
                                    //WebViewJavascriptBridge.callHandler('call_camera',{name:name, url:url}, function(response) {})      //传name和上传url参数
                                    var message = {
                                        'method' : 'openappurl',
                                        'params' : {
                                            'url' : url,
                                            'name': name
                                        }
                                    };
                                    window.webkit.messageHandlers.call_camera.postMessage(message);
                                }
                                
                            }
                            
                            /*
                             调用app接口是传token参数
                             */
                            
                            function refresh_token(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                var token =$("#token").val();
                                if(isAndroid){
                                    window.wst.refresh_token(token);
                                }else{
                                    //WebViewJavascriptBridge.callHandler('refresh_token',{token:token}, function(response) {})
                                    window.webkit.messageHandlers.refresh_token.postMessage();
                                }
                            }
                            
                            function show_token(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                if(isAndroid){
                                    window.wst.show_token();
                                }else{
                                    //WebViewJavascriptBridge.callHandler('show_token','', function(response) {})
                                    window.webkit.messageHandlers.show_token.postMessage();
                                }
                            }
                            //调用app接口是传url参数，app端打开此url
                            function open_url(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                var url=$("#url").val()
                                if(isAndroid){
                                    window.wst.open_url(url);
                                }else{
                                    //WebViewJavascriptBridge.callHandler('open_url',{url:url}, function(response) {})
                                    var message = {
                                        'method' : 'openappurl',
                                        'params' : {
                                            'url' : url
                                        }
                                    };
                                    window.webkit.messageHandlers.open_url.postMessage(message);
                                }
                            }
                            
                            function alert_text(text){
                                alert(text)
                            }
                            
                            function logout(){
                                var message = {
                                    'method' : 'tobackpage'
                                };
                                window.webkit.messageHandlers.logout.postMessage(message);
                            
                            }
                            
                            
                            function call_qrscan(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                if(isAndroid){
                                    window.wst.call_qrscan();
                                }else{
                                    //WebViewJavascriptBridge.callHandler('call_qrscan','', function(response) {})
                                    window.webkit.messageHandlers.call_qrscan.postMessage();
                                }
                            }
                            
                            function call_local_qrscan(){
                                var ua = navigator.userAgent.toLowerCase();
                                var isAndroid = ua.indexOf("android") > -1;
                                if(isAndroid){
                                    window.wst.call_local_qrscan();
                                }else{
                                    //WebViewJavascriptBridge.callHandler('call_local_qrscan','', function(response) {})
                                    window.webkit.messageHandlers.call_local_qrscan.postMessage();
                                }
                            }
                            
                            function qrscan_callback(text){
                                alert(text);
                            }
                            
                            function pop() {
                                var message = {
                                    'method' : 'tobackpage'
                                };
                                window.webkit.messageHandlers.pop.postMessage(message);
                            }
                            
                                </script>
    </head>
    
    <body>
        
        
        <div class="left">
            <button onclick=logout()>返回</button><br />
            <button onclick=call_camera()>上传照片功能</button><br/>
            <!--<button onclick=call_mic()>上传音频功能</button><br/>
             <button onclick=call_mic2()>上传音频功能2</button><br/>
             <button onclick=get_location()>获取定位坐标</button><br/>
             <button onclick=call_qrscan()>调用二维码</button><br/>
             <button onclick=call_local_qrscan()>调用本地获取二维码功能</button><br/>-->
            <button onclick="logout()">登出</button><br/>
            <a href="http://aa.mysmartedu.com.cn/aapowerapi/demo.html?ori=l"><button>切换横屏</button></a><br/>
            <a href="http://aa.mysmartedu.com.cn/aapowerapi/demo.html?ori=p"><button>切换竖屏</button></a>
            <h1>修改本地Token</h1>
            <input name="token" placeholder="Token" id="token">
                <button class="b1" onclick=refresh_token()>修改本地</button><button class='b2' onclick=show_token()>查看当前</button>
                <h1 class="h1">Post Token 打开网页</h1>
                <input id="url" placeholder="输入网址" value="http://aa.mysmartedu.com.cn/aapowerapi/test2.php">
                    <button class='b3' onclick=open_url()>进入网页</button>
        </div>
        <div class="right">
            <h1>上传照片功能</h1>
            <p>点击后调用相机，拍照后进入预览页面，可点击重拍/上传</p>
            <ol>
                <li>上传文件名称</li>
                <li>上传文件接收程式路径</li>
                <li>上传压缩后jgp格式（1024px左右）</li>
            </ol>
            
            <!--<h1>上传音频功能</h1>
             <p>点击后调用录音蒙版，长按按钮录音后，可点击预览/重新录制/上传</p>
             <ol>
             <li>上传文件名称</li>
             <li>上传文件接收程式路径</li>
             <li>上传压缩后mp3格式</li>
             </ol>
             
             <h1>获取坐标功能</h1>
             <p>点击后，页面ECHO出坐标即可</p>-->
            
            <h1>修改本地token</h1>
            <p>点击修改，刷新APP中保存的本地TOKEN</p>
            <p>点击查看，Echo APP中保存的当前TOKEN</p>
            
            <h1>Post Token打开网页</h1>
            <p>点击后，打开新的Webview访问该网页，每个页面都PostAPP中保存的Token</p>
        </div>
    </body>
</html>

